//
//  IntExtesion.swift
//  JiaoZiTaxi
//
//  Created by Hu Gang on 2022/10/11.
//

import Foundation

extension Int {
  func secondsToHoursMinutesSeconds() -> (Int, Int, Int) {
    let seconds = self
    return (seconds / 3600, (seconds % 3600) / 60, (seconds % 3600) % 60)
  }

  func secondsToReadString() -> String {
    let seconds = self
    let r = (seconds / 3600, (seconds % 3600) / 60, (seconds % 3600) % 60)
    var s = ""
    if r.0 > 0 {
      s += "\(r.0)小时"
    }

    if r.1 > 0 {
      s += "\(r.1)分钟"
    }

    if r.2 > 0 {
      s += "\(r.2)秒"
    }

    return s
  }
}
